From 882290b479c02f2bc6d1d3d85b09dc3cc66dc9b9 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 11 Jan 2017 08:51:04 +0100 Subject: [PATCH] Skip dynamic type check in css value getters This gets called a lot during snapshotting, and this change alone brings down snapshot time by almost 10% in a syntethic snapshot test. --- gtk/gtkcssanimatedstyle.c | 5 ++--- gtk/gtkcssstaticstyle.c | 3 ++- gtk/gtkcssstyle.c | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c index 1e89088a6b..aadaf97173 100644 --- a/gtk/gtkcssanimatedstyle.c +++ b/gtk/gtkcssanimatedstyle.c @@ -44,7 +44,8 @@ static GtkCssValue * gtk_css_animated_style_get_value (GtkCssStyle *style, guint id) { - GtkCssAnimatedStyle *animated = GTK_CSS_ANIMATED_STYLE (style); + /* This is called a lot, so we avoid a dynamic type check here */ + GtkCssAnimatedStyle *animated = (GtkCssAnimatedStyle *) style; if (animated->animated_values && id < animated->animated_values->len && @@ -147,8 +148,6 @@ GtkCssValue * gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style, guint id) { - gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL); - return gtk_css_style_get_value (style->style, id); } diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c index 217bb06265..f8ce97003d 100644 --- a/gtk/gtkcssstaticstyle.c +++ b/gtk/gtkcssstaticstyle.c @@ -44,7 +44,8 @@ static GtkCssValue * gtk_css_static_style_get_value (GtkCssStyle *style, guint id) { - GtkCssStaticStyle *sstyle = GTK_CSS_STATIC_STYLE (style); + /* This is called a lot, so we avoid a dynamic type check here */ + GtkCssStaticStyle *sstyle = (GtkCssStaticStyle *) style; return sstyle->values[id]; } diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c index 1d607d8367..250371f7fe 100644 --- a/gtk/gtkcssstyle.c +++ b/gtk/gtkcssstyle.c @@ -69,8 +69,6 @@ GtkCssValue * gtk_css_style_get_value (GtkCssStyle *style, guint id) { - gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL); - return GTK_CSS_STYLE_GET_CLASS (style)->get_value (style, id); } -- 2.30.2